Skip to content

FOUR-31145: Self Service tasks not visible to users in assigned subgroups - #9022

Open
rodriquelca wants to merge 5 commits into
developfrom
bugfix/FOUR-31145
Open

rodriquelca wants to merge 5 commits into
developfrom
bugfix/FOUR-31145

Conversation

@rodriquelca

@rodriquelca rodriquelca commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

A Self Service task assigned to group Main does not show for a user who is only in subgroup Sub (Sub ∈ Main). Inbox/claim compared the token’s self_service_groups to the user’s direct groups only.

The task list also broke: exclude() used $this->table (null) and generated SELECT .id, so the API returned 422 and the tab looked empty.

Repro: Homero in Sub → Sub in Main → process Self Service assigned to Main → login as Homero → Tasks → Self Service. List is empty; claim fails. To Do empty until claim is expected.

Solution

  • User::selfServiceGroupIds() = direct groups + ancestors (Group::ancestorIdsFor()). Used by availableSelfServiceTasksQuery() and canSelfServe(). Token is not rewritten.
  • Cache 10 min; GroupMemberObserver invalidates on membership changes.
  • scopeExclude() uses getTable() so the list SELECT is valid.
self.services.mov

How to Test

Run the unit test
./vendor/bin/phpunit tests/Feature/SelfServiceSubgroupTest.php

Related Tickets & Packages

https://processmaker.atlassian.net/browse/FOUR-31145

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

ci:deploy

@nolanpro

nolanpro commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://ci-56d7fe3332.engk8s.processmaker.net

@pmPaulis
pmPaulis self-requested a review September 10, 2026 13:31
->all();

$queue = [];
foreach ($parents as $parentId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodriquelca Could changing this foreach to a while loop cause any performance issues? Could you analyze it and also check what happens if a group has a recursive assignment?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodriquelca consider to add a test with circular reference of groups:

Group0 -> Group1 -> Group0

Seems the code covers it but please include it in a test

@pmPaulis
pmPaulis self-requested a review September 18, 2026 17:02

@caleeli caleeli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test according to the previous comment (circular references)

@cursor

cursor Bot commented Sep 21, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes authorization and task visibility for self-service workflows via caching; incorrect invalidation could briefly expose or hide tasks, though feature tests cover common membership paths.

Overview
Fixes Self Service tasks assigned to a parent group not appearing for users who belong only to a nested subgroup, by resolving each user’s effective groups as direct memberships plus ancestor group IDs (Group::ancestorIdsFor) for canSelfServe, task listing, and inbox queries—without changing stored token self_service_groups.

Adds a 10-minute per-user cache for those IDs, with invalidation when user–group links change (UserGroups relation), group hierarchy rows change or groups are deleted (GroupMemberObserver, GroupObserver + hierarchy version bump), so removed memberships stop seeing tasks immediately.

Also fixes scopeExclude on ProcessMakerModel to qualify columns with getTable() instead of a null $this->table, which was breaking the tasks API SELECT and empty Self Service lists.

Reviewed by Cursor Bugbot for commit dc48f80. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2e362d7. Configure here.

Comment thread ProcessMaker/Observers/GroupMemberObserver.php
@rodriquelca
rodriquelca requested a review from caleeli September 21, 2026 13:50
@decisions-sonarqube

Copy link
Copy Markdown

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-56d7fe3332.engk8s.processmaker.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants